package com.nuc.zyt.framework.beans.factory.support;

import com.nuc.zyt.framework.beans.BeanDefinition;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName SimpleBeanDefinitionRegistry
 * @Description 注册表接口子实现类
 * @Author 耀酱
 * @Date 2023/6/5 19:36
 * @Version 1.0
 */

public class SimpleBeanDefinitionRegistry implements BeanDefinitionRegistry {
// 存储对象
    private Map<String,BeanDefinition> beanDefinitionMap = new HashMap<>();

    // 注册对象
    @Override
    public void registerBeanDefinition(String beanName, BeanDefinition bean) {
        beanDefinitionMap.put(beanName,bean);
    }

    @Override
    public void removeBeanDefinition(String beanName) {
        beanDefinitionMap.remove(beanName);
    }

    @Override
    public BeanDefinition getBeanDefinition(String beanName) {
        return beanDefinitionMap.get(beanName);
    }

    @Override
    public boolean containsBeanDefinition(String beanName) {
        return beanDefinitionMap.containsKey(beanName);
    }

    @Override
    public int getBeanDefinitionCount() {
        return beanDefinitionMap.size();
    }

    @Override
    public String[] getBeanDefinitionNames() {
        return beanDefinitionMap.keySet().toArray(new String[0]);
    }
}
